package com.zk.shop.servlet.sorts;

import com.zk.shop.entity.Sorts;
import com.zk.shop.service.Impl.SortsServiceImpl;
import com.zk.shop.service.SortsService;
import com.zk.shop.util.JSONServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName UpdateSortsServlet
 * @Description TODO
 * @Author 来永刚
 * @Date 2019/10/15 0015下午 7:11
 * @Version 1.0
 **/
@WebServlet("sorts/UpdateSortsServlet")
public class UpdateSortsServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String sortsname = req.getParameter("sortsname");
        int sortsid = Integer.parseInt(req.getParameter("sortsid"));
        System.out.println(sortsid);
        Sorts sorts =new Sorts(sortsid,sortsname);
        SortsService sortsService = new SortsServiceImpl();
        boolean flag = sortsService.updateSorts(sorts);
        JSONServlet.getJson(req,resp,flag);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
